﻿// ## 2023/09/28 # 氕氘氚 # 伤害设定优化 ##
// ## 2023/09/28 # 江东新风 # 初次编写 ##

namespace BURN_DAMAGE
{

	class Main
	{
		Main()
		{
			pk::set_func(219, pk::func219_t(callback));
		}

		//damage_type 0 兵力伤害， 1耐久伤害（只对建筑生效）
		int callback(pk::hex_object@ object, int damage_type)
		{
			float damage = 0.f;
			
			if (damage_type == 0)
			{
				
				damage = 人员基础燃烧伤害 * ch::randfloat(0.8, 1.2);
				damage += object.get_troops() * 人员燃烧比例伤害 / 100.f;

				if (object.is_instance(pk::building::type_id))
				{
					pk::building@ building = @object;
					if (pk::is_general_type(building) || ch::is_valid_spec_id(ch::get_spec_id(building)))
						damage *= 据点人员燃烧伤害倍率 / 100.f;
				}
				else if (object.is_instance(pk::unit::type_id))
				{
					pk::unit@ unit = @object;
					damage = batt::fire_def_skill_impact(int(damage), unit);	//计算伤害修正
				}
			}
			else
			{
				if (object.is_instance(pk::building::type_id))
				{
					pk::building@ building = @object;
					damage = 耐久基础燃烧伤害 * ch::randfloat(0.8, 1.2);
					damage += building.hp * 耐久燃烧比例伤害 / 100.f;
					if (pk::is_general_type(building) || ch::is_valid_spec_id(ch::get_spec_id(building)))
						damage *= 据点耐久燃烧伤害倍率 / 100.f;
				}
			}
			
			//pk::trace(pk::format("219 BURN_DAMAGE type={} {}", damage_type, int(damage)));

			return int(damage);
		}
	}

	Main main;
}